import { getComponentByType } from '@/components/questionComponents'
import { StateType } from '@/store'
import { FC } from 'react'
import { useSelector } from 'react-redux'
const ComponentProp: FC = () => {
  const { selectedId, componentList } = useSelector((state: StateType) => state.components)
  const selectedComponent = componentList.find(item => item.fe_id === selectedId)
  if (!selectedComponent) return null
  const { type, props, isHidden, isLocked } = selectedComponent
  const config = getComponentByType(type)
  if (!config) return null
  const { PropComponent } = config
  return <PropComponent {...props} disabled={isLocked || isHidden} />
}
export default ComponentProp
